package com.kclm.xsap.utils;

import java.util.HashMap;
import java.util.Map;

/**
 * Result  写了没用到 放着
 * @param <T>
 */
public class Result<T> {
    private int code;
    private String msg;
    private Map<String, T> data;

    public Result(int code, String msg, Map<String, T> data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static Result<Object> withCode(int code) {
        return new Result<>(code, null, null);
    }

    public Result<T> withMsg(String msg) {
        this.msg = msg;
        return this;
    }

    public Result<T> put(String key, T value) {
        if (data == null) {
            data = new HashMap<>();
        }
        data.put(key, value);
        return this;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Map<String, T> getData() {
        return data;
    }

    public void setData(Map<String, T> data) {
        this.data = data;
    }
}
